﻿using ObserverPattern.ObserverDemo;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace DesignPatternsC
{
    public class ObserverTest1
    {

        public static void Client()
        {
            //創建一個被觀察者
            Cat sub = new Cat();

            //創建一個觀察者，並觀察被觀察者
            sub.CatMiaoEvent += new Boy().BoyAction;
            sub.CatMiaoEvent += new Mother().MotherAction;
            sub.CatMiaoEvent += new Mouse().MouseAction; 

            Console.WriteLine(sub.MiaoEvent());
        }

        public static void Client1()
        {
            //創建一個被觀察者
            Cat sub = new Cat();

            //創建一個觀察者，並觀察被觀察者
            sub.AddObserver(new Boy());
            sub.AddObserver(new Mouse());
            sub.AddObserver(new Mother());
             
            Console.WriteLine(sub.MiaoObserver());
        }
    }
}
